libxl: fix error handling (xenstore transaction leak) in libxl__domain_make
authorIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 28 Jan 2011 18:34:52 +0000 (18:34 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 28 Jan 2011 18:34:52 +0000 (18:34 +0000)
commit1057300109ea61e32f5bfd84fb5454c599471516
treecd5f974424f54c096cf64591e88e91160e9235ad
parentc72092776211365cea1d24f93a3db9143e0b9491
libxl: fix error handling (xenstore transaction leak) in libxl__domain_make

libxl__domain_make could under some circumstances leak the xenstore
transaction (stored in the variable t).  Also, failures to commit the
xenstore transaction for reasons other than EAGAIN would be ignored (!)

Fix this as follows:

  * Initialise t to 0 (not a valid transaction id), and when the
    transaction is successfully committed or rolled back, reset it.

  * Change all the instances of:       libxl__free_all(&gc); return error;
    to instead do:                     rc=error;  goto out;

  * Use the out stanza for exiting, setting rc=0 on success first.

  * Explicitly abort the transaction in the out stanza.

Also add a note by the calls manipulating the gc, to note that as this
is an internal function, the gc should really be set up and destroyed
by its caller.  But let's not do that at this stage of the 4.1 release
cycle.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/libxl_create.c